﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace IPMsgMoTest.ViewModels
{
    public class ChatItemViewModel : INotifyPropertyChanged
    {
        private DateTime timeStamp;

        public DateTime TimeStamp
        {
            get { return timeStamp; }
            set
            {
                if (timeStamp != value)
                {
                    timeStamp = value;
                    this.NotifyPropertyChanged("TimeStamp");
                }
            }
        }

        private string chatContent;

        public string ChatContent
        {
            get { return chatContent; }
            set
            {
                if (chatContent != value)
                {
                    chatContent = value;
                    this.NotifyPropertyChanged("ChatContent");
                }
            }
        }

        private ChatType chatContentType = (ChatType)(-1);

        public ChatType ChatContentType
        {
            get { return chatContentType; }
            set
            {
                if (chatContentType != value)
                {
                    chatContentType = value;
                    if (value == ChatType.Send)
                    {
                        this.backColor = new SolidColorBrush(Color.FromArgb(100, 255, 255, 0));
                        this.halign = HorizontalAlignment.Right;
                    }
                    else
                    {
                        this.backColor = new SolidColorBrush(Color.FromArgb(100, 0, 255, 255));
                        this.halign = HorizontalAlignment.Left;
                    }

                    this.NotifyPropertyChanged("ChatContentType");
                    this.NotifyPropertyChanged("BackColor");
                    this.NotifyPropertyChanged("Halign");
                }
            }
        }
        private SolidColorBrush backColor;

        public SolidColorBrush BackColor
        {
            get { return backColor; }
            set { backColor = value; }
        }

        private HorizontalAlignment halign;

        public HorizontalAlignment Halign
        {
            get { return halign; }
            set { halign = value; }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (null != handler)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    public enum ChatType
    {
        Send = 0,
        Receive
    }
}
